package be.aquafin.klipdf.dao;


import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import be.aquafin.klipdf.model.KlipRequest;

public class KlipRequestDaoImpl implements KlipRequestDao {
	
	// thread-safe version of the EntityManager
	@PersistenceContext(unitName = "klipPersistenceUnit")
	private EntityManager klipEntityManager;

	@Override
	public List<KlipRequest> getAllKlipRequests() {
		return klipEntityManager.createQuery("from Klip_Aanvraag", KlipRequest.class).getResultList();
	}

	@Override
	public void deleteMapRequest(long mapRequestId) {
		Object entity = this.klipEntityManager.find(Object.class, "[id]");
		klipEntityManager.remove(entity);
	}

	@Override
	public void addMapRequest(KlipRequest mapRequest) {
		klipEntityManager.persist(mapRequest);
	}
	
	public void update(KlipRequest mapRequest) {
		klipEntityManager.merge(mapRequest);
	}
	
	
}
